package com.hhf.cloud.controller;

import com.hhf.cloud.resp.ResultData;
import com.hhf.cloud.service.AccountTccService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Daniel-黄海峰
 * @Description
 * @create 2024/3/2 22:00
 * TCC模式
 */
@RestController
public class AccountTccController {

    @Resource
    private AccountTccService accountTCCService;

    /**
     * 扣减账户余额TCC
     * 不懂TCC的，请看详细文档：https://seata.apache.org/zh-cn/blog/seata-tcc/
     */
    @PostMapping("account/decreasetcc")
    ResultData decreaseTcc(@RequestParam("userId") Long userId, @RequestParam("money") Long money)
    {
        accountTCCService.decreaseTcc(userId,money);
        return ResultData.success("tcc扣减账户余额成功！");
    }
}

